home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.19981211-19990422
/
000408_news@watsun.cc.columbia.edu _Thu Mar 25 17:17:19 1999.msg
< prev
next >
Wrap
Internet Message Format
|
1999-04-21
|
3KB
Return-Path: <news@watsun.cc.columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id RAA21425
for <kermit.misc@watsun.cc.columbia.edu>; Thu, 25 Mar 1999 17:17:18 -0500 (EST)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id QAA26899
for kermit.misc@watsun.cc.columbia.edu; Thu, 25 Mar 1999 16:50:37 -0500 (EST)
X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
From: dn5006@my-dejanews.com
Subject: Number with a personality
Date: Thu, 25 Mar 1999 21:35:22 GMT
Organization: Deja News - The Leader in Internet Discussion
Message-ID: <7dea6q$6r3$1@nnrp1.dejanews.com>
To: kermit.misc@watsun.cc.columbia.edu
; OBJECT-ORIENTED PROGRAMMING IN KERMIT 95
; THE FOLLOWING SCRIPT DEFINES A CLASS NUMBER WITH A RANGE
define number {
local self
assign self \%1
_assign \m(self).get {
echo \\m(\m(self).val)
return \m(\%v.val)
}
_define \m(self).set {
local \%v
assign \%v \fbreak(\v(macro), .)
\%v.range_check \%1 \m(\%v.max) \m(\%v.min)
if not success end 1
_assign \%v.val \%1
echo \m(\%v.val)
return \m(\%v.val)
}
_define \m(self).add {
local \%v \%s
assign \%v \fbreak(\v(macro), .)
assign \%s \m(\%v.val)
assign \%s \feval(\%s + \%1)
\%v.range_check \%s \m(\%v.max) \m(\%v.min)
if not success end 1
_assign \%v.val \%s
echo \m(\%v.val)
return \m(\%v.val)
}
_define \m(self).range_check {
if > \%1 \%2 end 1 too big
if < \%1 \%3 end 1 too small
}
_assign \m(self).destroy {
_define \m(self).val
_define \m(self).get
_define \m(self).add
_define \m(self).set
_define \m(self).range_check
}
\m(self).range_check \%2 \%4 \%3
xif not success {
\m(self).destroy)
end 1
} else {
_assign \m(self).val \%2
_assign \m(self).min \%3
_assign \m(self).max \%4
}
}
; THIS IS MY FIRST NUMBER THAT HAS AN INITIAL VALUE 18,
; ALLOWABLE RANGE 5 ... 20
number first_number 18 5 20
; I CHANGE ITS VALUE FROM 18 TO 9
first_number.set 9
; I ADD 5 TO IT
first_number.add 5
; I TRY TO SET IT TO 30 and FAIL
first_number.set 30
; I TRY ADD 21 TO IT AND FAIL
first_number.add 21
; ITS VALUE IS STILL 14
first_number.get
; I ERASE IT
first_number.destroy
; This is rather smalltalk or C++, Kermit 95 - what a cute language!
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own